package com.ruoyi.cmenonmetal.controller;

import com.ruoyi.cmenonmetal.domain.ZsDataPreprocess;
import com.ruoyi.cmenonmetal.service.IZsDataPreprocessService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 预处理Controller
 * 
 * @author zousong
 * @date 2022-02-17
 */
@RestController
@RequestMapping("/cmenonmetal/preprocess")
public class ZsDataPreprocessController extends BaseController
{
    @Autowired
    private IZsDataPreprocessService zsDataPreprocessService;

    /**
     * 查询预处理列表
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZsDataPreprocess zsDataPreprocess)
    {
        startPage();
        List<ZsDataPreprocess> list = zsDataPreprocessService.selectZsDataPreprocessList(zsDataPreprocess);
        return getDataTable(list);
    }

    /**
     * 导出预处理列表
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:export')")
    @Log(title = "预处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZsDataPreprocess zsDataPreprocess)
    {
        List<ZsDataPreprocess> list = zsDataPreprocessService.selectZsDataPreprocessList(zsDataPreprocess);
        ExcelUtil<ZsDataPreprocess> util = new ExcelUtil<ZsDataPreprocess>(ZsDataPreprocess.class);
        util.exportExcel(response, list, "预处理数据");
    }

    /**
     * 获取预处理详细信息
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zsDataPreprocessService.selectZsDataPreprocessById(id));
    }

    /**
     * 新增预处理
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:add')")
    @Log(title = "预处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsDataPreprocess zsDataPreprocess)
    {
        return toAjax(zsDataPreprocessService.insertZsDataPreprocess(zsDataPreprocess));
    }

    /**
     * 修改预处理
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:edit')")
    @Log(title = "预处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZsDataPreprocess zsDataPreprocess)
    {
        return toAjax(zsDataPreprocessService.updateZsDataPreprocess(zsDataPreprocess));
    }

    /**
     * 删除预处理
     */
    @PreAuthorize("@ss.hasPermi('cmenonmetal:preprocess:remove')")
    @Log(title = "预处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zsDataPreprocessService.deleteZsDataPreprocessByIds(ids));
    }
}
